package com.xjd.edu.common.config;

import lombok.Data;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import java.util.Map;

@Component("bizConfigProperties")
@Accessors(chain = true)
@ConfigurationProperties(prefix = "config")
@Data
@Slf4j
@Validated
public class BizConfig {

    private Evn evn = new Evn();

    private Oss oss = new Oss();

    private Elasticsearch elasticsearch = new Elasticsearch();

    private DingTalkConfig dingTalkConfig = new DingTalkConfig();

    //websocket配置
    private Ws ws = new Ws();

    @Data
    public static class Evn {
        private String prefix;
        private String testDiff;
    }

    @Data
    public static class Oss {
        private String endpoint;
        private String accessKeyId;
        private String accessKeySecret;
        private String bucketName;
        private String host;
        private String cdnHost;
    }

    @Data
    public static class Elasticsearch {
        private String host;
        private int readTimeout;
        private String indexDB;
        private String username;
        private String password;
        private Map<String, String> rollover;
        private Map<String, Integer> cleanup;
        private Boolean msgSaveSync;
        private Boolean msgSaveOldSync;
        private Boolean msgUpdateSync;
        private Boolean msgUpdateOldSync;
    }

    @Data
    public static class DingTalkConfig {
        private String webHookToken;
        private String lotteryWebHookToken; //xx预警群
        private String activityWebHookToken; //xx活动预警群
    }

    @Data
    public static class Ws {

        private String host;

        private String port;

        private String path;

        private String restUrl;
    }

}
